<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>qq注册</title>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
</head>
<body>
<center>
    <font color="red" size="7">qq注册页面</font>
    <br/>
    <input id="name" type="text" name="username"/> <span id="sp"></span> <br/>
    <input id="psw" type="password" name="password"/><br/>
    <input type="submit" value="注册"/>
</center>
</body>
<script>
    $(function () {
        $("#name").blur(function () {
            var name = $(this).val();
            $.ajax({
                url: 'user/checkName',
                type: 'post',
                contentType: 'application/json',
                data: name,
                success: function (ret) {
                    if (ret === "1") {
                        var $sp = $("#sp");
                        $sp.css("color","red");
                        $sp.text("恭喜您!可以注册!!");
                    } else {
                        var $sp = $("#sp");
                        $sp.css("color","red");
                        $sp.text("用户名已存在！");
                    }
                }
            })
        })
    })
</script>
</html>